Repository navigation
feat(plugin-auth): remove a pending person and retry every environment-user host call from a durable outbox - #34162
Conversation
Claude-Session: https://claude.ai/code/session_01L9qibx2sFAzcNAfxCPdUtF Co-authored-by: Claude <noreply@anthropic.com>
…weeps Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibx2sFAzcNAfxCPdUtF
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibx2sFAzcNAfxCPdUtF
…onment-user outbox object Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibx2sFAzcNAfxCPdUtF
… function Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibx2sFAzcNAfxCPdUtF
… boot; refresh the tenancy censuses Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibx2sFAzcNAfxCPdUtF
📓 Docs Drift CheckThis PR changes 1 package(s): 36 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 13 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 45f890bb22c1672d47f8a55159dda30ae16e94da && git checkout 45f890bb22c1672d47f8a55159dda30ae16e94da
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 2c96e0dfc9297ba791c8acb6484ebe678dfd7d12 2e868fa7e24849da3062c3616ba80594c206de7d && git checkout -B drift-repro 2c96e0dfc9297ba791c8acb6484ebe678dfd7d12 && git merge --no-ff 2e868fa7e24849da3062c3616ba80594c206de7d
node scripts/docs-audit/affected-docs.mjs --json 2c96e0dfc9297ba791c8acb6484ebe678dfd7d12
|
|
domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx Contract-review-claim: session_01L9qibzuZJBQY4wUQFJbkfx · head 17f7933 · 2026-11-15T22:33Z |
|
domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx Contract reviewServed-tier: Inputs read: card #33228 (body and its four comments), the ruling text on #33181 comment 6870710213, PR #34162 (body, 46 files, net diff against Check-runs on this head when read: 28 concluded ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Ruled terms, against the tree.
Should-fix 1 — an invitation can be sent for a person who is deactivated while pending. The invariant "a deactivated pending person holds no live invitation" is not held by the worker. Should-fix 2 — the remove door's "pending only" check is not held at the write. Should-fix 3 — on a kernel with a host wired that is not cloud-managed, the ban and unban doors queue rows no worker drains. Nits.
Per file. No must-fix. The three should-fixes earn a delta review of their fix. Implemented-by: VERDICT: PASS |
…rules No invitation is sent to a deactivated person; a removal holds to pending people at the write; calls are recorded only on a cloud-managed kernel, where the worker drains them. Prose says which calls are recorded. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibx2sFAzcNAfxCPdUtF
…-32vsaq # Conflicts: # packages/plugins/plugin-auth/src/pending-sso-users.ts
|
domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx Contract-review-claim: session_01L9qibzuZJBQY4wUQFJbkfx · head 01d65d8 · 2026-11-15T23:59Z |
|
domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx Contract reviewServed-tier: Delta review of record 6902610047 for the hop 17f7933..01d65d8: the fix commit 9bb42bb, and the merge 01d65d8 of Check-runs on this head when read: 13 concluded ① Derived judgments
② Semver levelUnchanged: ③ Boundary flags
④ Design judgment
Should-fix 1 (an invitation for a deactivated pending person): closed.
Should-fix 2 (pending only, held at the write): closed. The marker is re-read as the first step inside the removal's unit of work, and a person who is no longer pending is answered 409 and kept, with their grants and membership. The host call is no longer inside the gap. What remains is a check followed by a delete inside one unit, not a conditional delete; see the nits. Should-fix 3 (rows no worker drains off a managed kernel): closed. Nits the author reports fixed.
New in the fix, tried against the same invariants. Nits only.
Per file. No must-fix and no should-fix. Nits alone end the round. Implemented-by: VERDICT: PASS |
|
domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx Seat ACCEPT 6904031398 on #33228 at |
…ithout the framework outbox
Ruling A on the card: the remove door and the optional `userRemoved`
host member stay; durable retry and per-person invitation status are the
host's job. Drops `sys_environment_user_outbox`, its worker, boot and
accepted trigger, every outbox write in add/import/ban/unban/remove,
`deliveryId`, the `invitation` answer fields, the translation bundles and
the census/inventory/registry rows, so main is unchanged outside the door.
A removal that fails after the host took the cancellation sends the
invitation again once through `userAdded` and says whether it worked.
A deactivated pending person who is re-added is not invited: the answer
says `host: { notified: false, reason: 'deactivated' }`.
Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q4EjjPP1zuWBNq3nBXVei9
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjPP1zuWBNq3nBXVei9
|
repo:cloud#5 · hotlong · session_01Q4EjjPP1zuWBNq3nBXVei9 Contract review (delta, after ruling A)Served-tier: ① Derived judgments: right.
② Ruling A conformance: exact. On the head tree there are no hits for ③ Findings
Verdict: PASS with should-fix. S1 and S2 are sent back to the dev, with N1–N3, before landing. |
…and refuse it when the host is unreachable Delta review round on the reshaped door: - The sys_user delete carries `source: idp_pending` (a predicate delete, which honours deleteBehavior like the by-id one); a zero-row delete throws NoLongerPending, so a first sign-in committing inside the unit of work is answered 409 and the child deletes roll back. - A host that cannot be reached refuses the removal with 503 and nothing removed, as it refuses a deactivation: with no framework record nothing could ask the host again. The "not confirmed" sentence is gone with the path that produced it. - takeBackPerson's doc and throw text now hold for both callers. - A banned column read back as '1' or 'true' counts as deactivated. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjPP1zuWBNq3nBXVei9
…rs it, and prove the in-unit rollback The row delete carries `source: 'idp_pending'`, but on an object with cascading lookups the engine re-deletes by id after the cascade walk, so a first sign-in committing in that window is not yet refused (#34373, an engine defect). The docblocks, ledger note, docs and changeset now say so instead of claiming the window is closed. The in-unit sign-in test now runs the removal through the plugin's transactional seam (a snapshot transaction on the memory engine) and asserts the positions, permission sets and membership survive. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjPP1zuWBNq3nBXVei9
|
repo:cloud#5 · hotlong · session_01Q4EjjPP1zuWBNq3nBXVei9 ACCEPT · Head-sha: 席位核对
|
|
review#2 · os-project-manager · session_01FEkQ5mjfxPu5HKjUtuveBR Contract-review-claim: session_01FEkQ5mjfxPu5HKjUtuveBR · head 2e868fa · 2026-11-16T11:32Z |
|
review#2 · os-project-manager · session_01FEkQ5mjfxPu5HKjUtuveBR Contract reviewServed-tier: Inputs: card #33228 (body and all 13 comments, ruling A in 6910778242), the PR body, its 11-file list, the net diff against ① Derived judgments
② Semver level
③ Boundary flags
Earlier record 6912496390 (head
S1 (should-fix) — the host-failure rule for a removal is stated two ways. The code refuses (503). Three places in the head still say the removal proceeds: the N2 (nit) — the PR title names a durable outbox the tree does not have. It becomes the commit subject on N3 (nit) — a person removed by someone else between the first read and the unit of work answers 409 "not pending" rather than 404. No must-fix. One should-fix (S1). Implemented-by: VERDICT: PASS |
repo:cloud#5 · hotlong · session_01Q4EjjPP1zuWBNq3nBXVei9
Fixes #33228
Clause-②: yes (widening) — added:
POST /api/v1/auth/admin/remove-sso-user(platform administrators, cloud-managed environments only); an optionaluserRemovedmember onEnvironmentUserHostand the'removed'value ofEnvironmentUserEventKind; the'deactivated'value of the host outcome'sreason. Nothing that was accepted is refused.Metadata-protocol: none
维护者速读
POST /admin/remove-sso-user:邮箱输错、从未登录的人可以直接删掉,同时通知云端取消其邀请;已停用的待登录人员被重新添加时不再给他发邀请。OS_CLOUD_MANAGED=1时生效,只能删「待登录」的人;新接口和宿主可选成员都是加法,没有新表、没有迁移。云端暂时连不上时删除会被拒绝(503,人员保留,稍后重试即可),不会出现「本地删了、云端邀请还在」的情况。回滚即 revert 本 PR。唯一的行为变化是停用中的待登录人员被重新添加时不再通知云端(答复里写明deactivated)。packages/plugins/plugin-auth/src/pending-sso-users.ts的runRemoveSsoUser/takeBackPerson(删除行时带「待登录」条件)/removalNotDone(删除失败后的内联重新邀请),以及同文件addOnePendingPerson里停用判断那几行;其次environment-user-host.ts的hostMember回退。pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/pending-sso-users.test.ts,预期 74 个测试全部通过。What changes
Reshaped to ruling A on the card: the remove door and the host seam stay, and the framework keeps no outbox. Delivering a host call durably, and keeping each person's invitation status, is the host's job.
Remove door.
POST /api/v1/auth/admin/remove-sso-userwith{ "userId": "…" }, gated for platform administrators exactly asadd-sso-useris.409and removes no one.409(deactivate them instead). This also holds at the removal itself. The person is re-checked inside the unit of work, and thesys_userdelete carriessource: 'idp_pending'in itswhere(a predicate delete, which honoursdeleteBehaviorlike the by-id one). A delete that removes no row throws inside the unit of work, so the child deletes roll back. A person whose first sign-in lands while the host is asked is kept with409, and the answer says the host was already told.sys_userhas cascading lookups. For such an object the engine reads the matching ids, walks the cascade, and then deletes{ id: { $in } }with nosourcepredicate and no row lock. A first sign-in that commits between that read and that delete is still deleted and answered200. The docblocks, ledger note, docs and changeset all say so.404. A body with any key other thanuserIdanswers400.userRemoved. A host without that member is told throughuserDeactivatedwithsource: 'idp_pending', which by ruling already means "cancel the invitation".503 SERVICE_UNAVAILABLE("could not be reached … so they were not removed. Nothing was changed; try again."); the person is kept and no invitation is re-sent. The door calls the host once and keeps no record to ask again from, so removing the person would leave an invitation nothing could cancel.host: { notified: false, reason: 'no_host' }.deleteBehavior: 'restrict') answers the engine's refusal, and no one is removed. When the host had already taken the cancellation and the person is still pending and not deactivated, the door sends the invitation again inline, once, throughuserAdded. The answer says whether that worked ("it was sent again", or "sending it again did not succeed, so they stay pending with no invitation: add them again"). Nothing is retried later.A deactivated person is never sent an invitation (review#1 S1, the in-door half). Re-adding a pending person who is deactivated no longer calls
userAdded. The answer is200 alreadyPendingwithhost: { notified: false, reason: 'deactivated' }. Reactivating them (admin/unban-user) is what tells the host again. Abannedcolumn read back astrue,1,'1'or'true'counts as deactivated.Host contract.
EnvironmentUserHostgains an optionaluserRemoved(event), andEnvironmentUserEventKindgains'removed'. The seam's header now says each door calls the host once, and that a host which must not lose a call queues and retries it on its side.Also.
admin-platform-admin-standing,admin-route-nonadmin-refusal).content/docs/permissions/authentication.mdxdocuments the door, the deactivated re-add, and what is the host's job (durable delivery, per-person status, treating a repeat as harmless, cancelling byuserId, never by email address).Dropped from the earlier head
3c25103f(ruling A):sys_environment_user_outbox(object, platform-objects export,platform-object-names.tsrow, cli ownership inventory row, tenancy census rows and census-page figures, the 21 generated translation files);environment-user-outbox.ts(worker, lease, backoff, boot, accepted trigger) and its tests;deliveryIdonEnvironmentUserEvent;invitation: { id, status }answer fields;opts.retriedargument ofnotifyEnvironmentUserHost;Outside the files listed below, the tree is byte-identical to
main.admin-ban-endpoints.tsandmanifest.tsare back to main too.Tests
pending-sso-users.test.ts(+16 tests, 74 in the file):userRemovedfirst;userDeactivatedfallback for a host withoutuserRemoved;409, no host is called, and no one is removed;503: the person is kept, the host is asked once, and nothing is re-sent;no_host;restrictrefusal re-invites inline throughuserAdded;404,400(missing id, unknown key) and403(non-admin);409.userAddedand answersdeactivated;bannedcolumn read back as'1'or'true'is deactivated on a re-add;409;409, and their positions, permission sets and membership survive. The memory engine has no transaction, so the test gives it a snapshottransaction, which the plugin'srunAtomicallyseam calls. The test asserts that the removal entered that seam once and that the child rows were restored whenNoLongerPendingwas thrown. This proves the door's rollback path against the seam; on the real engine the window above still applies.Also: auth route ledger conformance, and the two dogfood admin sweeps.
Acceptance notes
sys_env_member_request(cloud PR ci: expand adr-anchors to the full authz/security ADR set — 8 → 15 (#4575 follow-up) #4594), which already handles invite / cancel / remove. A host that cannot be reached refuses the removal (503, nothing removed); the framework does not retry. Whether Setup → Users reads status through a host seam member or through cloud's table is decided on Setup → Users on a managed environment: add-person and CSV-import UI with per-row invitation status (reverses objectui#13330 for adding) #33187, not here.userAdded. It now calls nothing and answershost.reason: 'deactivated'. The request is not refused, and the answer gains a value (declared in theClause-②:line).sys_userremove action. The Setup → Users column and button stay with Managed environments: re-show the add-people actions in Setup → Users (reverse #25295 / #25309's visible predicates for adding) #33186 / Setup → Users on a managed environment: add-person and CSV-import UI with per-row invitation status (reverses objectui#13330 for adding) #33187.RESOURCE_CONFLICT,RESOURCE_NOT_FOUND,INVALID_REQUESTand the host's own codes.Verification
At head
2e868fa7e24(origin/main8436f67a2merged at1f1f43cbb), heavy runs under the shared verify lock.Gates
1f9b39d2606(the previous head):dispatch-gates --commands --repo objectstack-ai/objectstackderived 108 families. Each ran with stdin from /dev/null and its exit code was captured before any pipe. 106 exited 0.check:skill-examplesexited 3 (client-reactnot built), then 0 after a client-react build.check:dual-build-cjs-loadsexited 3 (needs a repo-wide build) and was NOT MEASURED locally;Lint & Repo Gatesran it in CI and succeeded.--ranwith:: exitcodes: "108 derived famil(ies) accounted for — 107 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)".2e868fa7e24changed only prose (a docblock, the ledger note, the docs paragraph and the changeset) and one test. Re-run locally: the gate subset that reads those files, 14 of 14 exit 0. They arecheck:doc-authoring,check:auth-mount-ledger,check-affected-docs,check-drift-comment,check-empty-changeset,check-changeset-no-major,check:nul-bytes,check:issue-citations(both forms),check:docs-transcript-drift,check:doc-anchors,check:cross-package-test-inputs,check:engine-double-contractandcheck:closed-ceremony-text. The full family set is declared to CI for this head.2e868fa7e24at write time: 33 success, 15 skipped, 4 in progress, none failed.Lint & Repo Gates,TypeScript Type Check,Build Core,Check ChangesetandGoverned Surface Queue Guardare success;Test Corewas in progress.pnpm lint,test:repo, and the dogfood battery (the title has no!andClause-②:has no narrowing arm).Tests
pnpm --filter @objectstack/plugin-auth test: Test Files 279 passed (279), Tests 5667 passed | 10 skipped (5677).pnpm --filter @objectstack/plugin-auth typecheck: exit 0.pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/pending-sso-users.test.ts: 74 passed.Ablations
Each mutation went through
scripts/ablation-replace.mjsin wrap mode (the anchor hit once and the mutation landed, verified against the blob). Each went red and was restored with blob == HEAD (the last two atd2608bc280f4) and an emptygit diff HEAD. The suite imports source, so nodist/leg applies.where: { id, source }reduced towhere: { id }): 1 failed (the in-unit sign-in case). Run at both1f9b39d26and2e868fa7e.takeBackPersonrun without its unit of work (await (unit ? unit.runAtomically(work) : work())reduced toawait work()), at2e868fa7e: 1 failed, the in-unit case ("the removal ran inside the transactional seam: expected +0 to be 1").isDeactivatedwithout the string forms: 1 failed ("a banned column read back as a string"). The first attempt was a no-op:ablation-replacerefused it because the replacement (a bare semicolon) was not distinct, and nothing ran. It was redone with a distinct replacement.userDeactivatedfallback disabled inhostMember: 1 failed.if (existing.deactivated)made false): 2 failed (the re-add case and the string-forms case).Generated by Claude Code